//
//  HttpConectionObject.h
//  jetplayerTestProject
//
//  Created by ott on 14-7-26.
//  Copyright (c) 2014年 ott. All rights reserved.
//

#import <Foundation/Foundation.h>
@class SPRequest;
@class HttpConectionObject;

@protocol HttpConectionDelegate <NSObject>
@optional
- (void) httpConection:(HttpConectionObject *)conection didFinish:(NSData *)data;
- (void) httpConection:(HttpConectionObject *)conection totalBytes:(NSUInteger)totalBytes sendBytes:(NSUInteger)sendBytes;
- (void) httpConection:(HttpConectionObject *)conection didFaild:(NSError *)error;
- (void) httpConectionHasCanceled:(HttpConectionObject *)conection;

@end

@interface HttpConectionObject : NSObject<NSURLConnectionDataDelegate,NSURLConnectionDelegate>
{
//    SPRequest *m_request;
    
    NSURLConnection *_conection;
    
    NSMutableData *_receiveData;
    
    NSUInteger _totalBytes;
    
    NSUInteger _sendBytes;
    
}

@property(nonatomic,assign) id<HttpConectionDelegate> delegate;

@property(nonatomic,retain) SPRequest *request;

-(id) initWithRequest:(SPRequest *)request delegate:(id<HttpConectionDelegate>)delegate;

- (void) start;

- (void) cancel;

@end
